import { AppNotification } from "../base";
import { asyncUniAPIWrap } from "@/utils/apiWrap";
import { AppNotificationEnum } from "../../eventSource/const";
import {
    GlobalNotificationHandleStatus,
    updateGlobalEventStatus,
    resetGlobalEventStatus,
} from "../../eventSource";
class LoginNotification extends AppNotification {
    constructor() {
        super();
    }

    // 先调用父类
    emits(...args: any): void {
        super.emits(...args);
        if (!GlobalNotificationHandleStatus.login) {
            resetGlobalEventStatus();
            // 标记登录完成
            updateGlobalEventStatus(AppNotificationEnum.login, true);
            // 去首页
            asyncUniAPIWrap("switchTab", {
                url: "/views/main/index/root/controller/index",
            });
        }
    }
}

const Login = new LoginNotification();

export { Login };
